
/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __LIGHT_VISUALIZER_H__
#define __LIGHT_VISUALIZER_H__

#include "NgPrerequisites.h"

namespace PQEngine
{

	/* The scene grid class that represent world horizontal space plane.
    */
	class LightVisualizer
    {
    public:
		static const unsigned int CIRCLE_VETEX_COUNT=32;
		static const unsigned int MODEL_VERTEX_COUNT=CIRCLE_VETEX_COUNT*4+8*2;//4 circles + 8 connecting lines construct the light model
		static const Ogre::String LIGHT_MANUAL_OBJ_NAME;
		static const Ogre::String LIGHT_MATERIAL_NAME;
		static const Ogre::String LIGHT_ENTITY_NAME;
		
	public:
		LightVisualizer(SceneObject* sceneObject);
		
		/*Set OGRE allowed light type.
		*/
		void setLightType(Ogre::Light::LightTypes type);

		void setSpotRange(Ogre::Degree innerAngle,Ogre::Degree outerAngle);
		void setSpotAttenuation(Ogre::Real attenuationRange);

		void show(bool show);
		void select(bool selected);
		inline bool isSelected()
		{
			return _selected;
		}

	private:
		void createLightVisualizer();
		void setModelMesh(Ogre::String meshName);
		
		void createPointLightGizmo();
		void createDirectionalLightGizmo();
		void createSpotLightGizmo();
		
		void drawCircle(const Ogre::Real radius, const Ogre::Real z, const Ogre::ColourValue& color);

	private:
		SceneObject* _sceneObject;//the scene owner of the visualizer ;
		Ogre::SceneManager* _sceneManager;
		Ogre::ManualObject* _visualObject;
		Ogre::MaterialPtr _material;
		Ogre::SceneNode* _sceneNode;
		Ogre::Entity* _entity;

		Ogre::Light::LightTypes _lightType;
		//Spot light specific
		Ogre::Radian _outerAngle;//
		Ogre::Radian _innerAngle;//
		Ogre::Real _attenuationRange;

		bool _show;
		bool _selected;
    };

}
#endif
